package Week1.J0415;
// 找出两个列表中的相交元素
import java.util.ArrayList;

public class ArrIntersection {
    public static void main(String[] args) {

    }

    public ArrayList<Integer> intersection (ArrayList<Integer> nums1, ArrayList<Integer> nums2) {
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < nums1.size(); i++) {
            for (int j = 0; j < nums2.size(); j++) {
                if (nums1.get(i).equals(nums2.get(j)) && !list.contains(nums1.get(i))) {
                    list.add(nums1.get(i));
                }
            }
        }
        return list;
    }
}
